﻿
@{
    ViewData["Title"] = "Edit";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<div id="divForm" style="margin:2px;padding:2px;">

    <el-form ref="form" :model="form" label-width="80px">
        <el-row :gutter="24">
            <el-col :span="6">
                <el-form-item label="环境编码" required>
                    <el-input v-model="form.envCode"></el-input>
                </el-form-item>
            </el-col>
        </el-row>
        <el-row :gutter="24">
            <el-col :span="6">
                <el-form-item label="环境名称" required>
                    <el-input v-model="form.envName"></el-input>
                </el-form-item>
            </el-col>
        </el-row>

        <el-row :gutter="24">
            <el-col :span="6">
                <el-form-item label="项目排序">
                    <el-input v-model="form.orderIndex" type="number"></el-input>
                </el-form-item>
            </el-col>
        </el-row>
        <el-row :gutter="24">
            <el-col :span="24">
                <el-form-item label="备注">
                    <el-input type="textarea" v-model="form.remark"></el-input>
                </el-form-item>
            </el-col>
        </el-row>
        <el-form-item>
            <el-button type="primary" @@click="SaveProject()" v-show="pageButtons.includes('saveenv')">保存</el-button>
            <el-button @@click="Back()">返回</el-button>
        </el-form-item>
    </el-form>
</div>
<style>
    .el-radio-button__inner, .el-radio-group {
        line-height: inherit !important;
    }

    .el-radio, .el-radio__input {
        line-height: inherit !important;
    }
</style>
<script>

    var vueProject = new Vue({
        el: '#divForm',
        created() {
            var _this = this;
            _this.GetEnvironmentModel();

            _this.$getMenuButtons();
        },
        methods: {
            GetEnvironmentModel() {
                var _this = this;
                _this.$get("@Url.Action("GetEnvironmentOutput", "Environment")?EnvId=" + _this.form.id).then((res) => {
                   // res.enabled = JSON.stringify(res.enabled);
                    _this.form = res;
                });
            },
            SaveProject() {
                var _this = this;
                _this.form.orderIndex = parseInt(_this.form.orderIndex);
               // _this.form.enabled = _this.form.enabled == "true" ? true : false;
                _this.$post("@Url.Action("SaveEnvironment", "Environment")", _this.form).then((res) => {
                    _this.form.id = res.data.id;
                    _this.$success(res.message, function () {
                        _this.$back(true);
                    });
                });
            },
            Back() { 
                this.$back();
            }
        },
        data() {
            return {
                pageButtons: [],
                form: {
                    id: getQueryString("id")||0,
                    envCode: "",
                    envName: "",
                    orderIndex: 0,
                    remark: ""
                }
            }
        }
    });
</script>
